package Orders;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * 自定义分区
 */
public class OrderPartition  extends Partitioner<OrderBean, NullWritable> {
    @Override
    public int getPartition(OrderBean orderBean, NullWritable nullWritable, int i) {
        // (key.hashCode() & 2147483647) % numReduceTasks
        return (orderBean.getOrder_id() & Integer.MAX_VALUE) % i;
        //id:000001 -> 1 % 3 =1
        //id:000002 -> 2 % 3 =2
        //id:000003 -> 3 % 3 =0
    }
}
